//
//  ContactTableViewCell.m
//  HomeWork_自定义Cell
//
//  Created by 黄威 on 16/6/21.
//  Copyright © 2016年 黄威. All rights reserved.
//

#define kWidth self.contentView.frame.size.width
#define kHeight self.contentView.frame.size.height

#import "ContactTableViewCell.h"
@interface ContactTableViewCell ()
@property (nonatomic, retain) UIImageView *image;
@property (nonatomic, retain) UILabel *name;
@property (nonatomic, retain) UILabel *QQ;

@end
@implementation ContactTableViewCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}


-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{

    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    
    if (self) {
        self.image = [[UIImageView alloc]init];
        
        [self.contentView addSubview:_image];
        
        self.name = [[UILabel alloc]init];
        [self.contentView addSubview:_name];
        
        self.QQ = [[UILabel alloc]init];
        [self.contentView addSubview:_QQ];
        
    }

    return self;

}

- (void)layoutSubviews {
    
   
    [super layoutSubviews];
    
 
    

    self.image.frame = CGRectMake(10, 10, kWidth * 0.3, kHeight - 20);
    self.image.backgroundColor = [UIColor orangeColor];
    
  
    self.name.frame = CGRectMake(_image.frame.size.width + 40, 20, kWidth * 0.5, kHeight * 0.2);
    self.name.backgroundColor = [UIColor greenColor];
    
    
    self.QQ.frame = CGRectMake(_name.frame.origin.x, kHeight * 0.2 + 40, kWidth * 0.5, kHeight * 0.2);
    self.QQ.backgroundColor = [UIColor blueColor];
    
}

/** 重写Model属性的setter方法. */

-(void)setModel:(Contact *)model{


    _name.text = model.name;
    
    _QQ.text = model.QQ;


}


    
    
    
    



































- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
